package com.macro.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.macro.enums.AppHttpCodeEnum;
import com.macro.mapper.UiCategoryMapper;
import com.macro.pojos.dto.ResponseResult;
import com.macro.pojos.pojo.UiCategory;
import com.macro.service.UiCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

@Service
public class UiCategoryServiceImpl implements UiCategoryService {

    @Autowired
    UiCategoryMapper uiCategoryMapper;

    @Override
    public ResponseResult queryCategory() {
        LambdaQueryWrapper<UiCategory> lambdaQueryWrapper = new LambdaQueryWrapper();
        lambdaQueryWrapper.eq(UiCategory::getIsDelete,false);
        List<UiCategory> uiCategories = uiCategoryMapper.selectList(lambdaQueryWrapper);
        if (CollectionUtils.isEmpty(uiCategories)){
            return ResponseResult.errorResult(AppHttpCodeEnum.DATA_NOT_EXIST);
        }
        return ResponseResult.okResult(uiCategories);
    }

}
